package com.gtw.modules.api.service.impl;

import com.gtw.modules.api.service.TbBannerService;
import com.gtw.modules.dao.TbBannerDao;
import com.gtw.modules.entity.TbBanner;
import com.gtw.modules.entity.TbCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;


@Service("bannerservice")
public class TbBannerServiceImpl implements TbBannerService {

    @Autowired
    private TbBannerDao tbBannerDao;

    @Override
    public TbBanner queryObject(Integer id) {
        return tbBannerDao.queryObject(id);
    }

    @Override
    public List<TbBanner> queryList(Map<String, Object> map) {
        return tbBannerDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return tbBannerDao.queryTotal(map);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public void save(TbBanner banner) {
        tbBannerDao.save(banner);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public void update(TbBanner banner) {
        tbBannerDao.update(banner);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public void delete(Integer id) {
        tbBannerDao.delete(id);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public void deleteBatch(Integer[] ids) {
        for (int i = 0; i < ids.length; i++) {
            TbBanner tbBannerEntity = tbBannerDao.queryObject(ids[i]);
            tbBannerEntity.setIsdelete(1);
            tbBannerDao.update(tbBannerEntity);
        }

    }

    @Override
    public List<TbBanner> findALL() {
        return tbBannerDao.findALL();
    }

}
